<?php

use yii\db\Migration;

class m000000_000003_create_system_error extends Migration
{
    public function safeUp()
    {
        $this->createTable('{{%system_error}}', [
            'id' => $this->primaryKey(),
            'time' => $this->integer()->notNull()->comment('时间'),
            'message' => $this->text()->notNull()->comment('内容'),
            'code' => $this->string(128)->comment('代码'),
            'file' => $this->string(128)->comment('文件'),
            'line' => $this->integer()->comment('行号'),
            'trace' => $this->text()->comment('追踪信息'),
            'context' => $this->text()->comment('环境信息'),
            'status' => $this->integer()->notNull()->comment('状态'),
        ]);
        $this->batchInsert('{{%key_map}}', ['t', 'k', 'v'], [
            ['system_error_status', 1, '待处理'],
            ['system_error_status', 9, '已处理'],
            ['system_error_status', 0, '已删除'],
        ]);
    }

    public function down()
    {
        $this->delete('{{%key_map}}', ['t' => 'system_error_status']);
        $this->dropTable('{{%system_error}}');
    }
}
